package com.qianfeng.ssm.dto;

import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import com.qianfeng.ssm.utils.ResultCode;

/**
 * @author Zhao_Win
 * @version V1.0
 * @Project AllDay
 * @Date 2022/3/10 16:10
 */
@Setter
@Getter
@ToString
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class Result {
    private int code;

    private String msg;

    private Object data;


    public static Result setOk(){
        return setOk(null);
    }

    public static Result setOk(Object data){

        return setOk(ResultCode.SUCCESS, "success", data);
    }

    public static Result setOk(int code,String msg,Object data){

        return setFail(code,msg,data);
    }

    public static Result setFail(int code,String msg,Object data){
        Result re = new Result();
        re.setCode(code);
        re.setMsg(msg);
        re.setData(data);
        return re;
    }

}
